import { createRouter, createWebHashHistory } from 'vue-router'
import Home from '../views/Home.vue'
import About from '../views/About.vue'
const HomeNews = () => import('../components/HomeNews.vue')
const HomeMsg = () => import('../components/HomeMsg.vue')

const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    name: 'Home',
    component: Home,
    children: [					// 子路由
      {
        path: '',					// 设置默认子路由
        component: HomeNews		// 不使用路由重定向
      },
      {
        path: 'news',				// 设置/home/news子路由
        component: HomeNews		// 设置匹配成功后所渲染的组件
      },
      {
        path: 'msg',				// 设置/home/msg子路由
        component: HomeMsg		// 设置匹配成功后所渲染的组件
      }
    ]
  },
  {
    path: '/about',
    name: 'About',
    component: About
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router